let bool: boolean = false;
console.log(111);
console.log(bool);

let myName: string = "hellow";
let myAge: number = 25;
let sentence: string = `Hello, my name is ${myName}. I'll be ${
  myAge + 1
} years old next month.`;

console.log(sentence);

let decLiteral: number = 6;
let hexLiteral: number = 0xf00d;
// ES6 中的二进制表示法
let binaryLiteral: number = 0b1010;
// ES6 中的八进制表示法
let octalLiteral: number = 0o744;
let notANumber: number = NaN;
let infinityNumber: number = Infinity;

let u: undefined = undefined;
let n: null = null;

// void限定的变量只能赋值null或者undefined：
let noContentb: void = null;
// 与null和undefined限定不同的是，null和undefined是所有类型的子类型：
let numbb: number = undefined; //这样没有问题
// 这样也不会报错
let ud: undefined;
let numb: number = u;
// 而void类型的变量不能互相随意传递：
let noContent: void;
// let numberr: number = noContent; // 报错

interface Person {
  name: string;
  age?: number;
  [propName: string]: any; //定义了任意属性取 string 类型的值  sexy
}

let tom: Person = {
  name: "Tom",
  age: 25,
}; // ok
let lilei: Person = {
  name: "Tom",
  age: 25, // error 缺少 age属性
  sexy: "name",// 错误 sexy属性并没有定义
};
console.log(tom);
console.log(lilei);

interface NumberArray {
  [index: number]: number;
}
let fibonacciA: NumberArray = [1, 1, 2, 3, 5];
let fibonacci: Array<number> = [1, 1, 2, 3, 5];
console.log(fibonacciA);
console.log(fibonacci);



// 函数声明

function sum(x: number, y: number): number {
  return x + y;
}

// 表达式声明方式
let mySum = function (x: number, y: number): number {
  return x + y;
};

interface SearchFunc {
  (source: string, subString: string): boolean;
}

let mySearch: SearchFunc;
mySearch = function(source: string, subString: string) {
  return source.search(subString) !== -1;
}